Skip to content

MAINT: Enforce ruff/flake8-comprehensions rules (C4) #1498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 22, 2025

Conversation

DimitriPapadopoulos
Copy link
Contributor

The C4 rules apply micro-optimisations that do result in faster code locally. However, in most cases, the global speed-up is imperceptible, as often with micro-optimisations. I think the actual purpose is consistent code, not speed, standardising on the most efficient Python construct.

These changes are debatable, some maintainers don't like them, as they don't find the resulting code more maintainable or readable. I could disable rules C401, C403 and C408 instead.

C401 Unnecessary generator (rewrite as a set comprehension)
C402 Unnecessary generator (rewrite as a dict comprehension)
C408 Unnecessary `dict()` call (rewrite as a literal)
@mattip mattip merged commit 013667f into airspeed-velocity:main May 22, 2025
15 checks passed
@DimitriPapadopoulos DimitriPapadopoulos deleted the C4 branch May 22, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants